/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Panels;

import constants.GameControllerServerConstants;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;

/**
 *
 * @author luc0
 */

public class RightClickOptionAndDeletePanel extends JPopupMenu {
    JMenuItem deleteItem;
    JMenuItem optionsItem;
    public RightClickOptionAndDeletePanel(final MouseEvent evt,final JLayeredPane panel,final JFrame optionFrame){
        deleteItem = new JMenuItem("Delete");
        deleteItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
               GameControllerServerConstants.isOptionInUse = false;
               panel.remove(((Component)evt.getSource()));
               panel.repaint();
            }
        });
        optionsItem = new JMenuItem("Options");
        optionsItem.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {            
            
            optionFrame.setVisible(true);
            }
        });
        add(deleteItem);
         this.addSeparator();
        add(optionsItem);
        addPopupMenuListener(new PopupMenuListener() {

            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
          
            }

            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
                
            }

            public void popupMenuCanceled(PopupMenuEvent e) {
                GameControllerServerConstants.isOptionInUse = false;
            }
        });

    }
}
